<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_REGISTRAR . 'sections.html'));
	
	$listCountStudentInformation = $DSC->getSeectionList($strAccDept); //COUNT

	if( $listCountStudentInformation > 0 ) {
		$countNum			= 20;
		$pagenum 			= $_GET["page_no"];
		$page_rows 			= $PAGINATION->numPerRow($countNum);
		$last 				= $PAGINATION->lastCeilPerRow($listCountStudentInformation, $page_rows);
		$pagenum 			= $PAGINATION->pageNumRow($pagenum, $last); 
		$pageLimit 			= $PAGINATION->limitRow($pagenum, $page_rows);
		
		$arrBut				= array('first' 	=> '<img src="' . DIR_IMAGES . 'pagination_first.png" title="First" border="0" />',
									'previous' 	=> '<img src="' . DIR_IMAGES . 'pagination_prev.png" title="Previous" border="0" />',
									'next' 		=> '<img src="' . DIR_IMAGES . 'pagination_next.png" title="Delete" border="0" />',
									'last' 		=> '<img src="' . DIR_IMAGES . 'pagination_last.png" title="Delete" border="0" />',);
		$classCSS			= array('button' 	=> 'pagination-button', 'label' 	=> 'pagination-label');
		$urlGet				= array('page' 		=> $_GET['page'], 		'search' 	=> $search);
		
		if( $listCountStudentInformation > $countNum ) {
			$pagination 	= $PAGINATION->pagination($arrBut, $pagenum, $last, $classCSS, $urlGet);
		}
	}
		
	$studList = $STUD->listStudentInformation($search, $pageLimit);
	
	# LSITING
	if ( !empty($studList) ) {
		
		$TEMP->set_block('handle',  'students', 'studentsRow');
		$bgcolor 	= LOOPING_F0F;
		$numCount 	= 1;
		
		if ( intval($_GET['page_no']) > 1 ) {
			$countNumSub = intval($_GET['page_no']);
			$numCount += intval($_GET['page_no'] - 1) * $countNum;
		}
			
		foreach($studList as $studListField => $studListValue) {
			
			$imgEnrollPayment  = '<a href="?page=StudentEnrollment&studid=' . $studListValue['stud_idPK'] . '&hash=' . hashrandom($studListValue['last_name'] . $listCoursesValue['first_name']) . '"><img src="' . DIR_IMAGES . 'icon/enroll.png" border="0" title="Enrollment"/></a>';
			$imgEnrollPayment .= '<a href="?page=StudentPayment&studid=' . $studListValue['stud_idPK'] . '&hash=' . hashrandom($studListValue['last_name'] . $listCoursesValue['first_name']) . '"><img src="' . DIR_IMAGES . 'icon/payment.png" border="0" title="Payment"/></a>';
			
			$studID = $studListValue['stud_idPK'];
			
			$semesterEnrollmentActive = $STUD->getSemesterEnrollmentActive($studID);
			
			/*
				stud_idPK
				course_idFK
				
			*/
			
			$edButton = '<div class="icon-button">
							&nbsp;<img src="' . DIR_IMAGES . 'icon/profile.png" border="0" title="View Profile" onclick="popupRequest(\'show\', \'StudentProfile\', \'Student Profile\', \'390\', \'500\', \'' . $studListValue['stud_idPK'] . '\');"/>
							<img src="' . DIR_IMAGES . 'icon/reports.png" border="0"/>&nbsp;' . $imgEnrollPayment . '</div>';
			
			$TEMP->set_var(array('stud_id' 		=> $studListValue['stud_idPK'],
								 'stud_no' 		=> $studListValue['stud_no'],
								 'name' 		=> $studListValue['last_name'] . ', ' . $studListValue['first_name'] . ' ' . $studListValue['middle_name'],
								 'course_code'	=> '<span class="blue-link" title="' . $studListValue['course_desc'] . '" onclick="popupRequest(\'show\', \'SubjectPrintPreview\', \'' . $studListValue['course_desc'] . ' (' . $studListValue['course_code'] . ')\', \'550\', \'1000\', \'' . $studListValue['course_idFK'] . '\');">' . $studListValue['course_code'] . '</span>' ,
								 'section_code'	=> 'Enrolled',
								 'is_deleted' 	=> ($studListValue['is_deleted'] == 'N') ? 'enabled' : 'disabled',
								 'numbering'	=> $numCount,
								 'bgcolor'		=> $bgcolor,
								 'ed_button'	=> $edButton
								));
								
			$TEMP->parse('studentsRow', 'students', true);
			$bgcolor = ($bgcolor == LOOPING_F0F) ? LOOPING_FFF : LOOPING_F0F;
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('stud_id' 		=> '',
							 'stud_no' 		=> '',
							 'name' 		=> 'No Record Found.',
							 'course_code'	=> '',
							 'section_code'	=> '',
							 'is_deleted' 	=> '',
							 'numbering'	=> '',
							 'bgcolor'		=> '',
							 'ed_button'	=> '',
							));
	}
	
	$TEMP->set_var(array('search' 			=> $search,
						 'pagination'		=> $pagination,
						 'results'			=> "<strong>" . $listCountStudentInformation . "</strong> results",
						 'urlPage'			=> $urlPage,
						 'reg_sub_menu'		=> $pageLib->registrarSubMenu(DIR_IMAGES),
						));
?>